package com.kania.todostack;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

public class SubjectView extends TextView{
	int left = 0, top = 0, right = 100, bottom = 10;
	SubjectData sdData;
	Handler hMain;
	int nTextSize = 10; // default

	public SubjectView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	public SubjectView(Context context, SubjectData sd, Handler handler){
		super(context);
		hMain = handler;
		sdData = sd;
		this.setText(sd.getSubjectName());
		this.setTextSize(12);
		this.setPadding(5, 1, 1, 1);
		this.setGravity(Gravity.CENTER_VERTICAL);
		this.setTextColor(Color.BLACK);
		//this.setBackgroundColor(Color.WHITE);
		this.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Message msg = Message.obtain();
				Bundle data = new Bundle();
				data.putInt("eventtype", Type.EVENTTPYE_TODO_INPUT);
				data.putInt("subnum", sdData.getSequenceNumber());
				msg.setData(data);
				hMain.sendMessage(msg);
			}
		});
		this.setOnLongClickListener(new View.OnLongClickListener() {
			@Override
			public boolean onLongClick(View v) {
				Message msg = Message.obtain();
				Bundle data = new Bundle();
				data.putInt("eventtype", Type.EVENTTPYE_SUB_INFO);
				data.putString("subinfo", sdData.getSubjectName());
				data.putInt("id", sdData.getID());
				data.putInt("subnum", sdData.getSequenceNumber());
				msg.setData(data);
				hMain.sendMessage(msg);
				return true;
			}
		});
	}
	
	
	/*
	public void onMeasure(int widthMeasuredSpec, int heightMeasuredSpec){
		setMeasuredDimension(viewWidth, viewHeight);
	}
	*/
}